package geektime.spring.springbucks.converter;

import java.nio.charset.StandardCharsets;
import org.joda.money.Money;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;

@WritingConverter
public class MoneyToBytesConverter implements Converter<Money,byte[]>{

  @Override
  public byte[] convert(Money money) {
    String vlaue = Long.toString(money.getAmountMajorLong());
    return vlaue.getBytes(StandardCharsets.UTF_8);
  }
}
